# Makefile for hexedit

PRODUCT = @PRODUCT@
VERSION = @VERSION@

SHELL = /bin/sh

CC = @CC@
CFLAGS = -g -O2 -Wall

LDFLAGS = @LDFLAGS@
LIBS = @LIBS@ -llua -lm -ltre
DEFS = @DEFS@
INSTALL = @INSTALL@

# Installation directories
prefix = @prefix@
exec_prefix = @exec_prefix@
mandir = @mandir@
bindir = @bindir@

INCL = @INCL@
SRCS = @SRCS@
OBJS = $(SRCS:.c=.o)

.SUFFIXES: .c .o .LC

.c.o:
	$(CC) $(DEFS) $(CFLAGS) -c $<

all: $(PRODUCT)

$(PRODUCT): $(OBJS)
	$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)

bookmarks.LC: bookmarks.lua
	lua bin2c.lua $< > $@

init.LC: init.lua
	lua bin2c.lua $< > $@

dhexview.o: dhexview.c bookmarks.LC init.LC
	$(CC) $(DEFS) $(CFLAGS) -c $<

clean:
	rm -rf *~ *.o core *.cache config.status config.log $(PRODUCT) *.LC

distclean: clean
	rm -f Makefile config.h

install: $(PRODUCT)
	$(INSTALL) -d -m 755 $(bindir)
	$(INSTALL) -s -m 755 $(PRODUCT) $(bindir)
	$(INSTALL) -d -m 755 $(mandir)/man1
	$(INSTALL) -m 644 $(PRODUCT).1 $(mandir)/man1
